'use strict';

/**
 * Config for the impl
 */
angular.module('app')
  .run(
    [          '$rootScope', '$state', '$stateParams',
      function ($rootScope,   $state,   $stateParams) {
          $rootScope.$state = $state;
          $rootScope.$stateParams = $stateParams; 
          $rootScope.sys={title:'BPP'};
      }
    ]
  )
  .config(
    ['$stateProvider', '$urlRouterProvider',
      function ($stateProvider,   $urlRouterProvider) {
          
          $urlRouterProvider
              .otherwise('/app/dashboard-v1');
          $stateProvider
              .state('app', {
                  abstract: true,
                  url: '/app',
                  templateUrl: 'tpl/app.html'
              })
              .state('app.dashboard-v1', {
                  url: '/dashboard-v1',
                  templateUrl: 'tpl/app_dashboard_v1.html',
                  resolve: {
                    deps: ['$ocLazyLoad',
                      function( $ocLazyLoad ){
                        return $ocLazyLoad.load(['js/controllers/chart.js']);
                    }]
                  }
              })
              .state('app.dashboard-v2', {
                  url: '/dashboard-v2',
                  templateUrl: 'tpl/app_dashboard_v2.html',
                  resolve: {
                    deps: ['$ocLazyLoad',
                      function( $ocLazyLoad ){
                        return $ocLazyLoad.load(['js/controllers/chart.js']);
                    }]
                  }
              })
              .state('app.ProcessDef', {
                  url: '/ProcessDef',
                  templateUrl: 'tpl/tplProcess/layout.html',
                  resolve: {
                      deps: ['$ocLazyLoad',
                        function( $ocLazyLoad){
                          return $ocLazyLoad.load('angularFileUpload').then(
                              function(){
                                 return $ocLazyLoad.load('js/controllers/file-upload.js');
                              }
                          );
                      }]
                  }
              }).state('app.ProcessDef.add', {
                  url: '/ProcessDef/{fold}',
                  templateUrl: 'tpl/tplProcess/deploy.html'
              }).state('app.ProcessDef.detail', {
                  url: '/detail/{defId}',
                  templateUrl: 'tpl/tplProcess/detail.html'
              }).state('app.ProcessDef.start', {
                  url: '/start/{defId}',
                  templateUrl: 'tpl/tplProcess/start-form.html'
              }).state('app.ProcessDef.process', {
                  url: '/task/getForm/{taskId}',
                  templateUrl: 'tpl/tplProcess/task/process-form.html'
              }).state('app.ProcessDef.task', {
                  url: '/task',
                  templateUrl: 'tpl/tplProcess/task/layout.html'
              }).state('app.ProcessDef.edit', {
                  url: '/edit/{defId}',
                  templateUrl: 'tpl/tplProcess/designer/modeler.html'
              })

      }
    ]
  );